﻿using UnityEngine;

/// <summary>
/// 激化元素
/// </summary>
public class QuickenAura : IElementAura
{
    private float _intervalTimer;
    private float _gauge;
    private float _gaugeLossSpeed;

    public GameObject Source { get; set; }

    /// <summary>
    /// 元素量
    /// </summary>
    public float Gauge
    {
        get => _gauge;
        set => _gauge = value <= 0f ? 0f : value;
    }

    public ElementType ElementType => ElementType.Grass;

    public bool IsGaugeLoss { get; set; }

    public void Attach(float gauge, GameObject source)
    {
        Gauge = gauge;
        Source = source;
        _gaugeLossSpeed = Gauge / (gauge * 5f + 6f);
    }

    public void Update(float deltaTime)
    {
        if (Gauge > 0f)
        {
            Gauge -= _gaugeLossSpeed * deltaTime;
        }
    }
}